package com.nuanshui.heatedloan.web;

import com.alibaba.fastjson.JSON;
import com.nuanshui.heatedloan.extension.fileupload.Progress;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import java.util.Map;

@Controller
@SessionAttributes("/cms/manage/status")
public class ProgressController {

	@RequestMapping(value = "/upfile/progress", method = RequestMethod.POST)
	@ResponseBody
	public String initCreateInfo(Map<String, Object> model) {
		Progress status = (Progress) model.get("status");
		if(status==null){
			return JSON.toJSONString(new Progress());
		}
		System.out.println(JSON.toJSONString(status));
		return JSON.toJSONString(status);
	}
	
	public static void main(String[] args) {
		Progress progress = new Progress();
		progress.setpBytesRead(100);
		progress.setpContentLength(100);
		System.out.println(JSON.toJSONString(progress));
	}
}